#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp_char(const void*e1,const void*e2)
{
    return strcmp( (char*)e1,(char*)e2 );
}
void swap(char* s1,char* s2,int weight)
{
    char temp;
    int i;
    for(i=0;i<weight;i++)
    {
        temp=*s1;
        *s1=*s2;
        *s2=temp;
         s1++;
         s2++;
    }
}
void my_qsort(void* pr,int len,int weight,int (*cmp)(const void*,const void*))
{
    int i,j;
    for(i=0;i<len-1;i++)
    {
        for(j=0;j<len-1-i;j++)
        {
            if( cmp( (char*)pr+j*weight,(char*)pr+(j+1)*weight )>0)
            {
                swap(  (char*)pr+j*weight,(char*)pr+(j+1)*weight,weight );
            }
        }
    }
}
int main()
{
    char arr[5][10]={"abcde","abcdce","efef","efeff","frgerge"};
    int sz= sizeof(arr)/sizeof(arr[0]);
    my_qsort(arr,sz,sizeof(arr[0]),cmp_char);
    int i;
    for(i=0;i<sz;i++)
        printf("%s ",arr[i]);
    return 0;
}
